#ifndef __PoolTest_H
#define __PoolTest_H

#include <cxxtest/TestSuite.h>
#include "../PoolElement.h" // TODO: remove
#include "../Pool.h"
// TODO: #include "../../core/Unit.h"
// TODO: retirar a testUnit
class testUnit : public PoolElement
{
    // METHODS
    public:
        testUnit () { /* Empty */ }        
        void reset () { /* Pure Virtual Method: Empty */ }
};

class PoolTest : public CxxTest :: TestSuite
{
    public:
        void test_create_units ()
        {
            for ( int i = 1 ; i < 21 ; i ++ )
            {
                tu[i-1] = pool.create();
                TS_ASSERT_EQUALS ( pool.get_size(), i );
            }
        }
        
        void test_units_IDs ()
        {
            for ( int i = 0 ; i < 20 ; i++ )
                TS_ASSERT_EQUALS ( tu[i].get_id(), i );
        }

        void test_destroy_units ()
        {
            for ( int i = 0 ; i < 10 ; i++ )
            {
                int s = pool.get_size();

                pool.destroy(tu[i]);
                TS_ASSERT_EQUALS ( pool.get_size(), s-1 );
            }
        }
        
        void test_units_IDs_after_removes ()
        {
            for ( int i = 0 ; i < 20 ; i++ )
            {
                if ( i < 10 )
                {
                    TS_ASSERT_EQUALS ( tu[i].get_id(), -1 );
                }
                else
                    TS_ASSERT_EQUALS ( tu[i].get_id(), i );
            }
        }

        void test_operator ()
        {
            for ( int i = 0 ; i < 20 ; i++ )
            {
                TS_ASSERT_EQUALS ( pool[i].get_id(), i );
            }
        }
        
    private:
        Pool<testUnit> pool;
        testUnit tu[20];
};

#endif
